//
//  FTSearchBar.m
//  项目2
//
//  Created by rimi on 16/8/19.
//  Copyright © 2016年 wzc. All rights reserved.
//

#import "FTSearchBar.h"

@implementation FTSearchBar
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIImage* clearImg = [self imageWithColor:[UIColor clearColor] andHeight:32.0f];
        self.searchBarStyle = UISearchBarStyleMinimal;
        [self setBackgroundImage:clearImg];
        [self setSearchFieldBackgroundImage:clearImg forState:UIControlStateNormal];
        [self setBackgroundColor:[UIColor clearColor]];
    }
    return self;
}
- (UIImage*) imageWithColor:(UIColor*)color andHeight:(CGFloat)height
{
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, height);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
